import Vue from 'vue'
import VueI18n from 'vue-i18n'
import store from '@/store'

import elementZhTwLocale from 'element-ui/lib/locale/lang/zh-TW' // element-ui lang
import elementZhCNLocale from 'element-ui/lib/locale/lang/zh-CN'// element-ui lang

import ZHTWLocale from './zh-TW'
import ZHCNLocale from './zh-CN'

Vue.use(VueI18n)

const messages = {
  'zh-CN': {
    ...ZHCNLocale,
    ...elementZhCNLocale
  },
  'zh-TW': {
    ...ZHTWLocale,
    ...elementZhTwLocale
  }
}

const i18n = new VueI18n({
  locale: store.state.app.language, // set locale
  messages // set locale messages
})

export default i18n
